﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lails.Config.Demo
{
    public class Config
    {
        public string AppID { get; set; }
    }
    class Program
    {
        static void Main(string[] args)
        {
            var config1 = ConfigLoader.Load<Config>("config.json");
            Console.WriteLine($"config1:{config1.AppID}");

            var config2 = ConfigLoader.Load<Config>("Config/config.json");
            Console.WriteLine($"config2:{config1.AppID}");

            var config3 = ConfigLoader.Load<Config>("app.json");
            Console.WriteLine($"config3:{config1.AppID}");

            var config4 = ConfigLoader.Load<Config>("Config/app.json");
            Console.WriteLine($"config4:{config1.AppID}");

            //通过Url加载
            //ConfigLoader.Load<Config>("http://config.lails.cc/application/service/application.config");

            var configServer = new ConfigServer<Config>("Config/config.json", 5);
            configServer.ConfigChanged += (s, e) =>
            {
                Console.WriteLine($"配置文件已更新, APPID:{configServer.Data.AppID}");
            };

            Console.Read();
        }
    }
}
